package com.server.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class FileUtil {

    public static String readAllFileText(String path) {
        return readAllFileText(path, "utf-8");
    }

    public static String readAllFileText(String path, String charset) {
        StringBuilder sb = new StringBuilder(1024);
        try (FileInputStream fs = new FileInputStream(new File(path))) {
            BufferedReader br = new BufferedReader(new InputStreamReader(fs, charset));
            while (true) {
                String line = br.readLine();
                if (line == null) {
                    break;
                }
                sb.append(line);
                sb.append("\n");
            }
        } catch (Exception e) {
        }
        return sb.toString();
    }
}
